var goodsRecordCtrl = new XFApp.client();
XFApp.client.prototype.quickGoodsrecord = {
	hgGoods : [],
	customers :[],
	successCode : "10000",
	defaultCustomerCode:"1020",
	hgPage : null,
	cusPage : null,
	goodsClassCode:null,
	urlItems : {
		queryHgGoodsByPageURL : basePath + "/nt/packageForstats/goodsRecord/queryHgGPage",
		queryCustomerByPageURL : basePath + "/nt/packageForstats/goodsRecord/queryCusPage",
		submitGoodsRUL : basePath +"/nt/packageForstats/goodsRecord/submitGoods",
		saveGoodsRUL : basePath +"/nt/packageForstats/goodsRecord/saveGoods",
		findDefaultCustomer : basePath +"/nt/packageForstats/goodsRecord/findDefaultCustomer",
		loadGoodsClassURL:basePath+"/nt/packageForstats/goodsRecord/loadGoodsClass",
		loadMainGoodsClassURL:basePath+"/nt/packageForstats/goodsRecord/loadMainGoodsClass"
	},
	initViewByGoods : function(){
		var _this = this;
		$("input[type='text']").each(function(){
			if(!!$(this).attr("name") && !!sku_goods[$(this).attr("name")]){
				$(this).val(sku_goods[$(this).attr("name")]);
			}
		});
		if(!!sku_goods.id){
			$("span.readonly").each(function(){
				var val = "";
				if(!!sku_goods[$(this).attr("name")]){
					val = sku_goods[$(this).attr("name")];
				}
				if($(this).hasClass("dataTime") && !!val){
					val = val.replace("T"," ");
				}
				if(!!val){
					$(this).text(val);
				}
			});
			var goods_status = "";
			for(index in stats_goodsStatus){
				var goodsStatus = stats_goodsStatus[index];
				if(goodsStatus.dictCode == sku_goods.docketstatus ){
					goods_status = goodsStatus.dictName;
				}
			}
			$("#docketstatus").text(goods_status);
			var apply_status = "";
			for(index in stats_approves){
				var approves = stats_approves[index];
				if(approves.dictCode == sku_goods.applystatus){
					apply_status = approves.dictName;
				}
			}
			
			$("#applystatus_des").text(apply_status);
			$("input[name='id']").val(sku_goods.id);
		}else{
			$("#base_info span.readonly").each(function(){
				var val = "";
				if(!!sku_goods[$(this).attr("name")]){
					val = sku_goods[$(this).attr("name")];
				}
				if($(this).hasClass("dataTime") && !!val){
					val = val.replace("T"," ");
				}
				if(!!val){
					$(this).text(val);
				}
			});
			$("span[name='docketCode']").text("");
		}
		$("#customSelect").attr("data-id",sku_goods["customscode"]);
		$("#customSelect").val(_this.selCustomerValue(sku_goods["customscode"]));
		$("#unit").attr("data-id",sku_goods["unit"]);
		$("#unit").val(_this.selUnitValue(sku_goods["unit"]));
		$("#unit1").attr("data-id",sku_goods["unit1"]);
		$("#unit1").val(_this.selUnitValue(sku_goods["unit1"]));
		$("#unit2").attr("data-id",sku_goods["unit2"]);
		$("#unit2").val(_this.selUnitValue(sku_goods["unit2"]));
		$("#mUnitSelect").attr("data-id",sku_goods["currency"]);
		$("#mUnitSelect").val(_this.selCurrencyValue(sku_goods["currency"]));
		this.initGoodsClass();
	},
	
	initGoodsClass : function(){
		var mainCode = sku_goods["mainClassDictCode"];
		var mainName = _this.selClassValue(classDictDataId,mainCode);
		$("#mainClassDictCode").attr("data-id",mainCode);
		$("#mainClassDictCode").val(mainName);
		var subDictData = this.loadGoodsClass(mainCode,mainName);
		$("#classDictDataId").attr("data-id",sku_goods["classDictDataId"]);
		$("#classDictDataId").val(_this.selClassValue(subDictData,sku_goods["classDictDataId"]));
	},
	initSelect : function(){
		var _this = this;
		$("#mUnitSelect").bsSuggest({
			idField: "dictCode",  
			keyField: "dictName",
			effectiveFields :["dictCode","dictName"],
			effectiveFieldsAlias:{dictCode:"编码",dictName:"名称"},
		    data: {
		        'value':currencys,
		    },
		    listStyle: {
                "padding-top": 0, "max-height": "240px", "max-width": "800px",
                "overflow": "auto", "width": "auto",
                "transition": "0.3s", "-webkit-transition": "0.3s", "-moz-transition": "0.3s", "-o-transition": "0.3s"
            }
		   });
		$("#unit").bsSuggest({
			idField: "dictCode",  
			keyField: "dictName",
			effectiveFields :["dictCode","dictName"],
			effectiveFieldsAlias:{dictCode:"编码",dictName:"名称"},
	        data: {
	           'value':units,
	        },
		    listStyle: {
                "padding-top": 0, "max-height": "240px", "max-width": "800px",
                "overflow": "auto", "width": "auto",
                "transition": "0.3s", "-webkit-transition": "0.3s", "-moz-transition": "0.3s", "-o-transition": "0.3s"
            }
	   });
		$("#unit1").bsSuggest({
			idField: "dictCode",  
			keyField: "dictName",
			effectiveFields :["dictCode","dictName"],
			effectiveFieldsAlias:{dictCode:"编码",dictName:"名称"},
	        data: {
	           'value':units,
	        },
		    listStyle: {
                "padding-top": 0, "max-height": "240px", "max-width": "800px",
                "overflow": "auto", "width": "auto",
                "transition": "0.3s", "-webkit-transition": "0.3s", "-moz-transition": "0.3s", "-o-transition": "0.3s"
            }
	   });
		$("#unit2").bsSuggest({
			idField: "dictCode",  
			keyField: "dictName",
			effectiveFields :["dictCode","dictName"],
			effectiveFieldsAlias:{dictCode:"编码",dictName:"名称"},
	       data: {
	           'value':units,
	       },
		    listStyle: {
                "padding-top": 0, "max-height": "240px", "max-width": "800px",
                "overflow": "auto", "width": "auto",
                "transition": "0.3s", "-webkit-transition": "0.3s", "-moz-transition": "0.3s", "-o-transition": "0.3s"
            }
	   });
		$("#customSelect").bsSuggest({
			idField: "dictCode",  
			keyField: "dictName",
			effectiveFields :["dictCode","dictName"],
			effectiveFieldsAlias:{dictCode:"编码",dictName:"名称"},
	        data: {
	            'value':customerCodes,
	        },
		    listStyle: {
                "padding-top": 0, "max-height": "240px", "max-width": "800px",
                "overflow": "auto", "width": "auto",
                "transition": "0.3s", "-webkit-transition": "0.3s", "-moz-transition": "0.3s", "-o-transition": "0.3s"
            }
	   });
		$("#mainClassDictCode").bsSuggest({
			idField: "dictCode",  
			keyField: "dictName",
			effectiveFields :["dictCode","dictName"],
			effectiveFieldsAlias:{dictCode:"编码",dictName:"名称"},
	        data: {
	            'value':classDictDataId,
	        },
		    listStyle: {
                "padding-top": 0, "max-height": "240px", "max-width": "800px",
                "overflow": "auto", "width": "auto",
                "transition": "0.3s", "-webkit-transition": "0.3s", "-moz-transition": "0.3s", "-o-transition": "0.3s"
            }
	   });
	   if(!!order_curtype){
			$("#mUnitSelect").attr("data-id",order_curtype);
			$("#mUnitSelect").val(_this.selCurrencyValue(order_curtype));
	   }
	},
	selCustomerValue : function(val){
		var text ;
		for(index in customerCodes){
			var code = customerCodes[index];
			if(code.dictCode == val){
				text = code.dictName;
			}
		}
		return text;
	},
	selUnitValue : function(val){
		var text ;
		for(index in units){
			var unit = units[index];
			if(unit.dictCode == val){
				text = unit.dictName;
			}
		}
		return text;
	},
	selCurrencyValue : function(val){
		var text ;
		for(index in currencys){
			var currency = currencys[index];
			if(currency.dictCode == val){
				text = currency.dictName;
			}
		}
		return text;
	},
	selClassValue : function(classData,val){
		var text ;
		for(index in classData){
			var cls = classData[index];
			if(cls.dictCode == val){
				text = cls.dictName;
			}
		}
		return text;
	},
	validForm : function(){
		var flag = true;
		$("span[required='required']").each(function(){
			if(!$(this).html()){
				flag = false;
				$(this).nextAll(".null_error").show();
			}
		});
		$("input[required='required']").each(function(){
			if(!$(this).val()){
				flag = false;
				$(this).nextAll(".null_error").show();
			}	
		});
		if(!$("#mUnitSelect").attr("data-id")){
			$("#mUnitSelect_span").show();
			flag = false;
		}
		
		/*if(!$("#mainClassDictCode").attr("data-id")){
			$("#mainClassDictCode_span").show();
			flag = false;
		}*/
		
		
		
		if(!$("#customSelect").attr("data-id")){
			$("#customscode_span").show();
			flag = false;
		}
		
		if(!$("#unit").attr("data-id")){
			$("#unit_span").show();
			flag = false;
		}
		if(!$("#unit1").attr("data-id")){
			$("#unit1_span").show();
			flag = false;
		}
		/*if(!$("#mainClassDictCode").attr("data-id")){
			$("#mainClassDictCode_span").show();
			flag = false;
		}*/
		$("input[isnumber='true']").each(function(){
			var reg = /^\d+(\.\d{1,5})?$/;
			if(!!$(this).val() && !reg.test($(this).val())){
				flag = false;
				$(this).nextAll(".type_error").show();
			}
			
			
			
		});
		var selectAlert = false;
		$("input.sug_select").each(function(){
			if(!!$(this).val() && !$(this).attr("data-id")){
				flag = false;
				selectAlert = true;
			}
			if(!$(this).val() && !!$(this).attr("data-id")){
				$(this).attr("data-id","");
			}
		});
		if(selectAlert){
			webDialogUtil.simpleAlert("请选择正确的选项", "温馨提示"); 
		}
		return flag;
	},
	queryPage : function(){
		_this = this;
		var params = {
			gcode : $("#gcodeFilter").val(),
			gname : $("#gnameFilter").val()
		}
		if(!!_this.hgPage){
			_this.hgPage.page("remote",0,params);
		}else{
			_this.hgPage = $("#page").page({
				pageSize : 5,
				remote: {
					url: _this.urlItems.queryHgGoodsByPageURL,
			        params: params, 
			        success: function (data, pageIndex) {
			        	if(data.code==_this.successCode){
			        		var pageResult = data.result;
			        		_this.hgGoods = pageResult.itemList;
			        		if(pageResult == null || pageResult.itemList == null || pageResult.itemList.length==0){
			        			$("#data_grid").html('<tr><td align="center" colspan="11">暂无数据</td></tr>');
			        		}else{
			        			$("#data_grid").html($("#dataTmp").render(pageResult.itemList));
			        		}
			        	}else{
			        		 webDialogUtil.simpleAlert(data.msg, "温馨提示"); 
			        	}
			        },
			        error : function(){
			        	 webDialogUtil.simpleAlert("数据查询异常，请联系开发人员", "温馨提示"); 
			        }
				},
				firstBtnText : '首页',
				lastBtnText : '尾页',
				prevBtnText : '上一页',
				nextBtnText : '下一页',
				showInfo : true,
				showJump : true,
				jumpBtnText : '跳转',
				showPageSizes : true,
				infoFormat : '共{pageCount}页'
			});
		}
	},
	queryCusPage : function(){
		_this = this;
		var params = {
			docketCode : $("#customercodeFilter").val(),
			docketName : $("#customernameFilter").val()
		}
		if(!!_this.cusPage){
			_this.cusPage.page("remote",0,params);
		}else{
			_this.cusPage = $("#customer_page").page({
				pageSize : 5,
				remote: {
					url: _this.urlItems.queryCustomerByPageURL,
			        params: params, 
			        success: function (data, pageIndex) {
			        	if(data.code==_this.successCode){
			        		var pageResult = data.result;
			        		_this.customers = pageResult.itemList;
			        		if(pageResult == null || pageResult.itemList == null || pageResult.itemList.length==0){
			        			$("#customer_data_grid").html('<tr><td align="center" colspan="11">暂无数据</td></tr>');
			        		}else{
			        			$("#customer_data_grid").html($("#cusDataTmp").render(pageResult.itemList));
			        		}
			        	}else{
			        		webDialogUtil.simpleAlert(data.msg, "温馨提示"); 
			        		 
			        	}
			        },
			        error : function(){
			        	webDialogUtil.simpleAlert("数据查询失败，请联系开发人员", "温馨提示"); 
			        }
				},
				firstBtnText : '首页',
				lastBtnText : '尾页',
				prevBtnText : '上一页',
				nextBtnText : '下一页',
				showInfo : true,
				showJump : true,
				jumpBtnText : '跳转',
				showPageSizes : true,
				infoFormat : '共{pageCount}页'
			});
		}
	},
	
	
	isSubmiting : false,
	goodsSubmit : function(){
		_this = this;
		if(!_this.validForm()){
			return;
		}
		this.generalSubmitGoods(_this.urlItems.submitGoodsRUL,"提交",1);
		this.isSubmiting = false;
	},
	goodsSave : function(){
		if(!_this.validForm()){
			return;
		}
		this.generalSubmitGoods(_this.urlItems.saveGoodsRUL,"暂存",0);
		this.isSubmiting = false;
	},
	
	generalSubmitGoods : function(url,type,tip){
		if(this.isSubmiting){
			return;
		}
		this.isSubmiting = true;
		var docket = {};
		var errText = "";
		$("input[type='text']").each(function(){
			if($(this).hasClass("sug_select")){
				docket[$(this).attr("name")] = $(this).attr("data-id");
			}else{
				docket[$(this).attr("name")] = $(this).val();
			}
		});

		$("#base_info span[type='text']").each(function(){
			if(!!$(this).text()){
				docket[$(this).attr("name")] = $(this).text();
			}
		});
		
		
		if(tip == 0){
			
			$.ajax({
				url:url,
				data:docket,
				dataType:'json',
				type:'post',
				success:function(data){
					if(data.code!=10000){
						webDialogUtil.simpleAlert(data.msg, "温馨提示");
					}else{
						  /**
						   * 重刷页面数据
						   */
						  sku_goods = JSON.parse(data.result);
						  goodsRecordCtrl.quickGoodsrecord.initViewByGoods(); 
						  if(type=="提交"){
							  $("#submit_btn").hide();
							  $("#save_btn").hide();
							  $("#reset_btn").hide();
							  $("#add_btn").attr("href",basePath+"/nt/packageForstats/goodsRecord/viewAdd?itemNo="+sku_goods.itemno);
							  $("#add_btn").show();
							  $("#goBack_btn").show();
						  }
						  var awbNo = $("#awbNo").val();
						  if(!!awbNo && type=="提交"){
							  webDialogUtil.callbackConfrimAlert("提交成功，是否返回运单页？",function(){
								  window.location.href=basePath+"/nt/parcelOrder/index?awbNo="+awbNo;
							  },"温馨提示");
						  }else{
							  webDialogUtil.simpleAlert(type+"成功", "温馨提示");
						  }
						 
					}
				},
				error:function(){
					 webDialogUtil.simpleAlert(type+"出现异常，请联系开发人员", "温馨提示");
				}
			});
		}
		else{

			webDialogUtil.simpleConfrimAlert('是否确认'+type+'?', function(){
		    	$.ajax({
					url:url,
					data:docket,
					dataType:'json',
					type:'post',
					success:function(data){
						if(data.code!=10000){
							webDialogUtil.simpleAlert(data.msg, "温馨提示");
						}else{
							  /**
							   * 重刷页面数据
							   */
							  sku_goods = JSON.parse(data.result);
							  goodsRecordCtrl.quickGoodsrecord.initViewByGoods(); 
							  if(type=="提交"){
								  $("#submit_btn").hide();
								  $("#save_btn").hide();
								  $("#reset_btn").hide();
								  $("#add_btn").attr("href",basePath+"/nt/packageForstats/goodsRecord/viewAdd?itemNo="+sku_goods.itemno);
								  $("#add_btn").show();
								  $("#goBack_btn").show();
							  }
							  var awbNo = $("#awbNo").val();
							  if(!!awbNo && type=="提交"){
								  webDialogUtil.callbackConfrimAlert("提交成功，是否返回运单页？",function(){
									  window.location.href=basePath+"/nt/parcelOrder/index?awbNo="+awbNo;
								  },"温馨提示");
							  }else{
								  //webDialogUtil.simpleAlert(type+"成功", "温馨提示");
								  webDialogUtil.simpleAlertWithCloseCallBack(type+"成功", "温馨提示",function(){
								  	  goodsBatchCommit.goodsCommit.viewData = goodsBatchCommit.goodsCommit.getGoodsViewData();
									  $("#goods_batch_commit_modal_gname").html(goodsBatchCommit.goodsCommit.viewData.gname);
									  $("#goods_batch_commit_modal").modal()
									  if(!$("#goodsNum").val()) $("#goodsNum").attr('value',10);
									  goodsBatchCommit.goodsCommit.giveSegmentValue();
								  });
							  }
							 
						}
					},
					error:function(){
						 webDialogUtil.simpleAlert(type+"出现异常，请联系开发人员", "温馨提示");
					}
				});
		   });
		}
		
	},
	
	
	
	/**
	 * 联动选择海关商品信息
	 */
	selGcode : function(gcode){
		var selHggoods = null;
		for(var index = 0;index<this.hgGoods.length;index++){
			var tmpGoods = this.hgGoods[index];
			if(tmpGoods.gcode == gcode){
				selHggoods = tmpGoods;
				break;
			}
		}
		/**
		 * 联动填充数据
		 */
		if(!!selHggoods){
			$("input[name='gcode']").val(selHggoods.gcode);
			$("input[name='gname']").val(selHggoods.gname);
			
			$("#unit").attr("data-id",selHggoods.unit1);
			$("#unit").val(_this.selUnitValue(selHggoods.unit1));
			$("#unit1").attr("data-id",selHggoods.unit1);
			$("#unit1").val(_this.selUnitValue(selHggoods.unit1));
			$("#unit2").attr("data-id",selHggoods.unit2);
			$("#unit2").val(_this.selUnitValue(selHggoods.unit2));
		}
		$("#choose_goods_modal").modal('hide'); 
	},
	/**
	 * 联动选择海关商品信息
	 */
	selCustomer : function(cusNo){
		var selCustomer = null;
		for(var index = 0;index<this.customers.length;index++){
			var tmpCustomer = this.customers[index];
			if(tmpCustomer.docketCode == cusNo){
				selCustomer = tmpCustomer;
				break;
			}
		}
		/**
		 * 联动填充数据
		 */
		if(!!selCustomer){
			$("#customer_name_span").hide();
			$("input[name='customercode']").val(selCustomer.docketCode||"");
			$("span[name='customername']").text(selCustomer.docketname||"");
			$("span[name='ebpcode']").text(selCustomer.ebpcode||"");
			$("span[name='ebpname']").text(selCustomer.ebpname||"");
			$("span[name='ebccode']").text(selCustomer.ebccode||"");
			$("span[name='ebcname']").text(selCustomer.ebcname||"");
			$("span[name='agentcode']").text(selCustomer.agentcode||"");
			$("span[name='agentname']").text(selCustomer.agentname||"");
		}
		$("#choose_customer_modal").modal('hide'); 
	},
	/**
	 * 默认的信息
	 */
	defaultValue : function(){
		var _this = this;
		$.ajax({
			url:_this.urlItems.findDefaultCustomer,
			data:{defaultCustomerCode:_this.defaultCustomerCode},
			dataType:'json',
			type:'post',
			success:function(data){
				if(data.code!=10000){
					 webDialogUtil.simpleAlert(data.msg, "温馨提示");
				}else{
					var customer = data.result; 
					if(!customer){
						webDialogUtil.simpleAlert("未找到默认客户信息", "温馨提示");
						return;
					}
					$("input[name='customercode']").val(customer.docketCode);
					$("span[name='customername']").text(customer.docketname);
					$("span[name='ebpcode']").text(customer.ebpcode);
					$("span[name='ebpname']").text(customer.ebpname);
					$("span[name='ebccode']").text(customer.ebccode);
					$("span[name='ebcname']").text(customer.ebcname);
					$("span[name='agentcode']").text(customer.agentcode);
					$("span[name='agentname']").text(customer.agentname);
				}
			},
			error:function(){
				webDialogUtil.simpleAlert("查询默认客户信息异常", "温馨提示");
			}
		});
		
		$("#customSelect").attr("data-id",1925);
		$("#customSelect").val(_this.selCustomerValue(1925));
		
		$("#mUnitSelect").attr("data-id",502);
		$("#mUnitSelect").val(_this.selCurrencyValue(502));
		
	},
	resetInfo : function(){
		$("input").each(function(){
			if(!$(this).hasClass("notReset")){
				$(this).val("");
				if(!!$(this).attr("data-id")){
					$(this).attr("data-id","");
				}
			}
		});
	},
	loadGoodsClass : function(goodsDictCode,goodsDictName){
		var subClassData = null;
		if(!goodsDictCode){
			$("#classDictDataId").bsSuggest("destroy");
			$("#classDictDataId").val("").attr("data-id","");
			this.goodsClassCode = null;
			return;
		}
		if(!this.goodsClassCode || this.goodsClassCode != goodsDictCode){
			this.goodsClassCode = goodsDictCode;
			$("#classDictDataId").bsSuggest("destroy");
			$("#classDictDataId").val("").attr("data-id","");
		}else{
			return;
		}
		var params = {
				goodsDictCode:goodsDictCode,
				goodsDictName:goodsDictName
		}
		$.ajax({			   
			url:_this.urlItems.loadGoodsClassURL,
			data:params,
			dataType:'json',
			type:'post',
			async:false,
			success:function(data){
				if(data.code!=10000){
					webDialogUtil.simpleAlert("查询子类商品失败", "温馨提示");
				}else{
					var classDictData = data.result;
					var newClassDictData = [];
					for(var index = 0;index<classDictData.length;index++){
						var data = classDictData[index];
						
						var newData = {
								dictCode:data.dictCode,
								dictName:data.dictName
						}
						newClassDictData.push(newData);
					}
					$("#classDictDataId").bsSuggest("destroy");
					$("#classDictDataId").bsSuggest({
						idField: "dictCode",  
						keyField: "dictName",
						effectiveFields :["dictCode","dictName"],
						effectiveFieldsAlias:{dictCode:"编码",dictName:"名称"},
				        data: {
				            'value':newClassDictData,
				        }
				   });
				   subClassData = newClassDictData;
				}
			},
			error:function(data){
				webDialogUtil.simpleAlert("查询子类商品异常", "温馨提示");
			}
		});
		return subClassData;
	},
	/**
	 * 绑定页面事件
	 */
	event : function(){
		_this = this;
		$("#goods_choose").on("click",function(){
			if(sku_goods!=null&&sku_goods.hgcodeFrom==1){
				$("#gnameFilter").val(sku_goods.itemname);
			}
			$("#choose_goods_modal").modal();
			_this.queryPage();
		});
		$("#btn_customer_choose").on("click",function(){
			$("#choose_customer_modal").modal();
			_this.queryCusPage();
		});
		$("#btn_customer_remove").on("click",function(){
			$("input[name='customercodeFilter']").val("");
			$("input[name='customernameFilter']").val("");
			$("input[name='customercode']").val("");
			$("span[name='customername']").val("");
			
			$("span[name='ebpcode']").val("");
			$("span[name='ebpname']").val("");
			$("span[name='ebccode']").val("");
			$("span[name='ebcname']").val("");
			$("span[name='agentcode']").val("");
			$("span[name='agentname']").val("");
		});
		$("#btn_goods_remove").on("click",function(){
			$("input[name='gcodeFilter']").val("");
			$("input[name='gnameFilter']").val("");
			$("input[name='gcode']").val("");
			$("input[name='gname']").val("");
			$("select[name='unit']").val("");
			$("select[name='unit1']").val("");
			$("select[name='unit2']").val("");
		});
		$("#submit_btn").on("click",function(){
			_this.goodsSubmit();
		});
		$("#save_btn").on("click",function(){
			$(".help-block").hide();
			_this.goodsSave();
		});
		$("#reset_btn").on("click",function(){
			_this.resetInfo();
		});
		$("#goods_search").on("click",function(){
			_this.queryPage();
		});
	
		$("#goods_reset").on("click",function(){
			$("input[name='gcodeFilter']").val("");
			$("input[name='gnameFilter']").val("");
		});
		$("#custom_serach").on("click",function(){
			_this.queryCusPage();
		
		});
	
		$("#custom_reset").on("click",function(){
			$("input[name='customercodeFilter']").val("");
			$("input[name='customernameFilter']").val("");
		});
		$("input[required='required']").on("keyup",function(){
			if(!!$(this).val()){
				$(this).nextAll("span").hide();
			}
		});
		$("input[required='required']").on("blur",function(){
			if(!!$(this).val()){
				$(this).nextAll("span").hide();
			}
		});
		
		$("input[name='prodweight']").on("keyup",function(){
			if(!!$(this).val()){
				$(this).nextAll("span").hide();
			}
		});
		$("input[name='prodweight']").on("blur",function(){
			if(!!$(this).val()){
				$(this).nextAll("span").hide();
			}
		});
		
	
		$("#mUnitSelect").on("keyup",function(){
			if(!!$(this).val()){
				$("#mUnitSelect_span").hide();
			}
		});
		$("#mUnitSelect").on("blur",function(){
			if(!!$(this).val()){
				$("#mUnitSelect_span").hide();
			}
		});
		
		$("#unit").on("keyup",function(){
			if(!!$(this).val()){
				$("#unit_span").hide();
			}
		});
		$("#unit").on("blur",function(){
			if(!!$(this).val()){
				$("#unit_span").hide();
			}
		});
		$("#unit1").on("keyup",function(){
			if(!!$(this).val()){
				$("#unit1_span").hide();
			}
		});
		$("#unit1").on("blur",function(){
			if(!!$(this).val()){
				$("#unit1_span").hide();
			}
		});
		$("#customSelect").on("keyup",function(){
			if(!!$(this).val()){
				$("#customscode_span").hide();
			}
		});
		$("#customSelect").on("blur",function(){
			if(!!$(this).val()){
				$("#customscode_span").hide();
			}
		});
		
		
		/*$("#mainClassDictCode").on("keyup",function(){
			if(!!$(this).val()){
				$("#mainClassDictCode_span").hide();
			}
		});*/
		
		$("#mainClassDictCode").on("blur",function(){
			if(!!$(this).val()){
				$("#mainClassDictCode_span").hide();
			}			
			//加载子类
			_this.loadGoodsClass($(this).attr("data-id"),$(this).val());
		});
	},
}

$(function(){
	goodsRecordCtrl.quickGoodsrecord.initSelect();
	goodsRecordCtrl.quickGoodsrecord.event();
	if(!!sku_goods){
		goodsRecordCtrl.quickGoodsrecord.initViewByGoods();
	}else{
		goodsRecordCtrl.quickGoodsrecord.defaultValue();
	}
	if(!!historyBackParams){
		var jsonObjStr = JSON.stringify(historyBackParams);
		goodsRecordCtrl.setCookie(cookieHistoryBackParamsName, jsonObjStr,1,"/");
	}
});